<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

		<link rel="stylesheet" type="text/css" href="../css/index.css" />
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			document.addEventListener('plusready', function() {
				//console.log("所有plus api都应该在此事件发生后调用，否则会出现plus is undefined。"

			});
		</script>
		<title></title>
		<style type="text/css">
			body {
				background-color: #fafafa;
			}

			#uppwd {
				margin-bottom: 10px;
			}

			#img>img {
				width: 70px;
				height: 70px;
				margin-top: 10px;
				margin-left: 10px;
				border-radius: 35px;
			}

			#span_right {
				margin-left: 20px;
			}

			#login {
				margin-top: 20px;
			}

			#one {
				background-color: red;
				height: 50px;

			}



			.van-nav-bar__title {
				color: white;
				font-size: 15px;
				padding-top: 5px;
			}

			.van-nav-bar .van-icon {
				color: white;

				padding-top: 10px;
			}

			.van-nav-bar__text {
				color: white;
				padding-top: 10px;
			}

			#info {
				margin-top: 20px;
				padding-left: 180px;
			}

			#dl {
				padding-left: 50px;
				padding-right: 50px;
				margin-bottom: 20px;
				margin-top: 20px;
			}
		</style>
	</head>

	<body>
		<div id="app">
			<van-row>
				<van-nav-bar left-arrow title="地址" left-text="返回" right-text="删除" id="one" @click-left="back" @click-right="Right"></van-nav-bar>
				<van-address-list v-model="chosenAddressId" :list="list" @add="addd"  @edit="onEdit"></van-address-list>
			</van-row>
			<van-row id="three">
			</van-row>
		</div>
		<script type="text/javascript">
			var key = localStorage.getItem("keys");
			ajax({
				url: "http://dsapi.ysd3g.com/API/MyShippingAddressList",
				dataType: "JSONP",
				data: {
					key:key
				},
				success: function(res) {
					console.log(res);
					for (var i = 0; i < res.Data.length; i++) {
						app.list.push(res.Data[i]);
					}
				}

			});
			var app = new Vue({
				el: "#app",
				data: {
					chosenAddressId: "1",
					list: []
				},
				methods: {
					back: function() {

						plus.webview.close(plus.webview.currentWebview());
					},
					addd: function() {

						plus.webview.open("add-address.html", "ind")
					},
					onEdit:function(){
						plus.webview.open("editAddress.html","edit");
					},
					Right:function(){
						var key = localStorage.getItem("keys");
						ajax({
							url: "http://dsapi.ysd3g.com/api/DeleteShippingAddress",
							dataType: "JSONP",
							data: {
								key:key,
								addressId: app.chosenAddressId
							},
							success: function(res) {
								window.location.reload();
							}

						});
					}
				}
			});
		</script>
	</body>

</html>
